{% extends "layouts/layout.html" %}
{% block title %}
My Items
{% endblock %}
{% block includes %}
<script type="text/javascript" src="/js/users	/users.js"></script>
{% endblock %}
{% block content %}
<h3>{{ li.get_display_name() }}'s Shop</h3>

{% if can_show %}
<table style="width:100%">
	<tr>
		<td style="width:128px; padding:10px;">
			{{ li.display_avatar() }}
		</td>
		<td>
			<p>Seller rating: <strong>{% if li.get_average_rating() %}{{ li.get_average_rating() }} / 5.00 {% else %} None {% endif %}</strong></p>
			<p>Description: <textarea class="readonlyRichText" style="width: 100%;" rows="5">{{li.desc}}</textarea></p>
		</td>
	</tr>
</table>
<hr />
<table style="width:100%">
	<tr>
		<td style="width:0%">
			
		</td>
		<td style="width:100%">
			<h4>{{ li.get_display_name() }}'s Items</h4>
			<table class="table table-striped">
			  <tr>
			    <th {% if current_li.user_id == li.user_id %} width="15%" {% else %} width="50%" {% endif %}>Expiration Date</th><th>Title</th>
				{% if current_li.user_id == li.user_id %}
					<th>Edit</th><th>Delete</th>
				{% endif %}
			  </tr>
				{% for item in items %}
				<tr>
			    <td>{{item.expiration_date.strftime("%m/%d/%Y")}}</td>
					<td>
						<a href="/items/view_item?item_id={{ item.key().id() }}">
							<div>{{ item.title }}</div>
						</a>
					</td>
				{% if current_li.user_id == item.created_by_id %}
			    <td>
			      <div><a class="btn" href="/items/edit_item?item_id={{ item.key().id() }}">Edit Item</a></div>
			    </td>
			    <td>
			      <div><a class="btn" href="/items/delete_item?item_id={{ item.key().id() }}&xsrf_token={{ xsrf_token }}" onclick="return confirm('Are you sure?');">Delete Item</a></div>
			    </td>
				{% endif %}
				</tr>
				{% endfor %}
			</table>
			{% if current_li.user_id == li.user_id %}
			<p style="text-align:right"><a class="btn" href="/items/new_item">New Item</a></p>	
			{% endif %}
		</td>		
	</tr>
</table>

<table style="width:100%">
	<tr>
		<td style="width:0%">
			
		</td>
		<td style="width:100%">
			<h4>{{ li.get_display_name() }}'s Collections</h4>
			<table class="table table-striped">
			  <tr>
			    <th>Title</th>
          {% if current_li.user_id == li.user_id %}
            <th>Delete</th>
          {% endif %}
			  </tr>
				{% for collection in collections %}
				<tr>
					<td>
						<a href="/items/view_collection?collection_id={{ collection.key().id() }}">
							<div>{{ collection.title }}</div>
						</a>
					</td>
				{% if current_li.user_id == collection.created_by_id or current_li.is_admin %}
			    <td>
			      <div><a class="btn" href="/items/delete_collection?collection_id={{ collection.key().id() }}&xsrf_token={{ xsrf_token }}" onclick="return confirm('Are you sure?');">Delete Collection</a></div>
			    </td>
				{% endif %}
				</tr>
				{% endfor %}
			</table>
			{% if current_li.user_id == li.user_id %}
			<p style="text-align:right"><a class="btn" href="/items/new_collection">New Collection</a></p>	
			{% endif %}
		</td>		
	</tr>
</table>

{% else %}
<div class="alert">
  <strong>Uh oh!</strong> This user is marked as private.
</div>
{% endif %}

{% endblock %}
